This page last changed on Apr 09, 2007 by cholmes.

Namespace

A Namespace is used to discriminate XML vocabularies from one another. All WFS's make use of three standard namespaces -

#WFS - http://www.opengis.net/wfs
#GML - http://www.opengis.net/gml
#Filter - http://www.opengis.net/ogc

Additionally, each WFS will use one or more 'Application Schemas'. GML is a sort of meta language from which more specific languages can be defined. A WFS makes use of one or more of these specific languages to describe its schemas - returned by the DescribeFeatureType response. The XML schema that it returns defines that more specific language, of what a 'road' can be, for example. These schemas should have their own namespaces. GeoServer comes with a few sample namespaces, but keep in mind these are just samples. If you are serving a public GeoServer it is essential to define your own namespace.

The default sample namespace is

http://www.openplans.org/topp

All namespaces are URI's - Uniform Resource Identifiers. They are like URLs (the L is for location), except they do not need to point to a specific location on the web. They only need to be a unique identifier. Using the same base URI as a URL that you have registered is highly recommended, however, since it is highly unlikely that someone else is using that same identifier (and indeed would be a little weird, someone defining identifiers on a space that you own. But it could be valid, since as we said a URI is just an identifier, it need not point to a location). So we recommend that you define the URI to perhaps the same URL that it is served from, with perhaps a different trailing identifier, such

http://www.myblorg.org/geo

To configure a namespace hit the Namespace link from the main Data page. This will take you to the following page:

There will be a few pre-configured namespaces, which you can edit and delete if you so desire, but we recommend that you hit the New button to create your own. This will have you first define a 'prefix'. In XML aprefix is used as shorthand for a full namespace. So instead of having to say:

<http://www.openplans.org/topp:bc_roads fid="bc_roads.1">
   <http://www.openplans.org/topp:the_geom>
   <http://www.opengis.net/gml:MultiLineString srsName="EPSG:27354">
..

You can simply define your prefixes at the top of the document:

...
xmlns:topp="http://www.openplans.org/topp"
xmlns:gml="http://www.opengis.net/gml"
...

and then you just have to say:

<topp:bc_roads fid="bc_roads.1">
  <topp:the_geom>
  <gml:MultiLineString srsName="EPSG:27354">
...

Note that GeoServer takes care of all of this for you, you just need to define the namespace and the prefix, and then decide which namespace you want your featureType to live in. Also note that GeoServer completely handles multiple namespaces, doing all the work for you, so you just need to define them, and GeoServer will return all the appropriate imports and XML namespacing in the DescribeFeatureType responses.

In GeoServer the prefix is very important, as it is also used internally. In true XML the namespace mapping should be completely arbitrary, but for GeoServer we are not quite there yet for all requests, so requests should be made using the appropriate prefix. This is what pretty much everyone does automatically, indeed most people don't know that you can do things differently, so we feel that this is a fine shortcut to take. It is essential that you always do include the namespace definitions for your requests to GeoServer, however, or things will often not work as expected. We recommend a prefix four or less characters in length. Three seems to be pretty standard, but plus or minus one does not hurt anyone. More than that and you start to lose some of the point of defining a prefix, as it's meant as shorthand. After defining the prefix you will be taking to the Namespace editor page (you can also get here later by selecting your namespace from the drop down list and then clicking 'Edit'):

On this page you will define the URI, which as we said, should be a unique identifier for your features. Using the GeoServer defaults is a bad idea, as your features are not coming from The Open Planning Project, or Axios. In the future we are looking to support better mapping from data to pre-defined schemas, based on some good thinking and experiments from Social Change Online for the Australian Government. See the roadmap in the wiki for more information. When this is available you will define the namespace, and indeed the schema itself, in a known 'information community', so that the attributes mean the same thing, achieving true interoperability.

Additionally, from the main Namespace page you can define the 'default' namespace. Just hit the 'Default' button when the namespace you would like to default is shown in the pull down box. An astrix by it will indicate that it is in fact the default. The default namespace has two special properties in GeoServer. First, kvp requests can be made on it without using its prefix. This is to some extent a holdover to the transition from single namespace to multiple namespaces. And the default will also be at the top of the drop down box when you define a DataStore, saving you an extra mouse click.


namespace.jpg (image/jpeg)
namespace-editor.jpg (image/jpeg)
Document generated by Confluence on Jan 16, 2008 23:27